From 90058ed951e7dd44ee2b5b2d6108bd043caaf2a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?utf8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Tue, 28 May 2019 16:14:39 +0000 Subject: [PATCH] Don't assume that gdk_surface[_move]_resize() is asynchronous On Windows that call resizes the native window immediately, and the corresponding GDK event is emitted and processed before the control is returned to gtk_window_move_resize(). Therefore, update freeze and configure_request_count increment must happen before the call, not after it. --- gtk/gtkwindow.c | 52 +++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 5cb64664d8..eae7baaec0 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -7485,6 +7485,35 @@ gtk_window_move_resize (GtkWindow *window) * we don't get the ConfigureNotify back, the resize queue will never be run. */ + if (priv->type != GTK_WINDOW_POPUP) + { + /* Increment the number of have-not-yet-received-notify requests. + * This is done before gdk_surface[_move]_resize(), because + * that call might be synchronous (depending on which GDK backend + * is being used), so any preparations for its effects must + * be done beforehand. + */ + priv->configure_request_count += 1; + + gdk_surface_freeze_toplevel_updates (surface); + + /* for GTK_RESIZE_QUEUE toplevels, we are now awaiting a new + * configure event in response to our resizing request. + * the configure event will cause a new resize with + * ->configure_notify_received=TRUE. + * until then, we want to + * - discard expose events + * - coalesce resizes for our children + * - defer any window resizes until the configure event arrived + * to achieve this, we queue a resize for the window, but remove its + * resizing handler, so resizing will not be handled from the next + * idle handler but when the configure event arrives. + * + * FIXME: we should also dequeue the pending redraws here, since + * we handle those ourselves upon ->configure_notify_received==TRUE. + */ + } + /* Now send the configure request */ if (configure_request_pos_changed) { @@ -7510,29 +7539,6 @@ gtk_window_move_resize (GtkWindow *window) gtk_widget_size_allocate (widget, &allocation, -1); } - else - { - /* Increment the number of have-not-yet-received-notify requests */ - priv->configure_request_count += 1; - - gdk_surface_freeze_toplevel_updates (surface); - - /* for GTK_RESIZE_QUEUE toplevels, we are now awaiting a new - * configure event in response to our resizing request. - * the configure event will cause a new resize with - * ->configure_notify_received=TRUE. - * until then, we want to - * - discard expose events - * - coalesce resizes for our children - * - defer any window resizes until the configure event arrived - * to achieve this, we queue a resize for the window, but remove its - * resizing handler, so resizing will not be handled from the next - * idle handler but when the configure event arrives. - * - * FIXME: we should also dequeue the pending redraws here, since - * we handle those ourselves upon ->configure_notify_received==TRUE. - */ - } } else { -- 2.30.2